function S4() {
	return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
}

function NewGuid() {
	return (S4() + S4() + S4() + S4() + S4() + S4() + S4() + S4());
}

function SaveImage(source,success,error) {
			console.log("adfadf");
	html2canvas(source).then(function (canvas) {
		
		var imageData = canvas.toDataURL(1);
		//image.src = imageData;

		var bitmap = new plus.nativeObj.Bitmap();
		bitmap.loadBase64Data(imageData, function () {
			//    console.log(‘加载图片成功‘);
			var path = "_doc/" + NewGuid() + ".png";
			bitmap.save(path, {
				overwrite: true,
				quality: 100
			}, function (i) {

				plus.gallery.save(path, function () {
					plus.nativeUI.closeWaiting();
					success(path);
				}, function () {
					plus.nativeUI.closeWaiting();
					error("保存失败");
				})

			}, function (e) {
				plus.nativeUI.closeWaiting();
				toast("保存失败");
			});
		}, function (e) {
			plus.nativeUI.closeWaiting();
			toast("保存失败");
		});

	});
}
